/** @file GroupLoader.qml
@brief The Qt-Complex loader for the dynamic qml document loading mechanism

This loader is used internally by the framework to load variable group of objects

@authorname \n
@licenseversion \n
@actualversion - @dateupdate

@licensenote
*/

import QtQuick 1.0

// The loader element surrounded by its item
Item {
    id: itemLoader

    // Loader properties to be assigned in the program
    property string obj: ""     // Object to load
    property string theme: ""   // Theme name
    // The following properties are used by the loaded

    property string obj_string: ""      // Generic string assigned to fields, buttons, etc.
    property string obj_message: ""     // Generic message assigned to text
    property string obj_icon: ""        // Generic icon assigned to buttons
    property string obj_background: ""  // Generic background assigned to the object
    property bool obj_flag: false       // Generic flag to enable/disable object options
    property bool obj_info: true        // Flag to enable / disable the info icon for the fields.

    // Geometry parameters
    property int fontPoints: 10                 // Base text font size in points
    property int fontSwitches: 10               // Switch text description font size in points
    property int fieldSpacing: 5                // Distance between fields

    // The signals connected with the object types
    signal clicked
    signal switched(bool status)

    Loader {
        id: objLoad
        // Inline functions returning the requested property
        function getString() { return itemLoader.obj_string; }
        function getMessage() { return itemLoader.obj_message; }
        function getIcon() { return itemLoader.obj_icon; }
        function getInfoFlag() { return itemLoader.obj_info; }
        function getBackground() { return itemLoader.obj_background; }
        function getTheme() { return itemLoader.theme; }
        function getFlag() { return itemLoader.obj_flag; }
        // Geometry methods
        function getWidth() { return itemLoader.width; }
        function getHeight() { return itemLoader.height; }
        function getFontPoints() { return itemLoader.fontPoints; }
        function getFontSwitches() { return itemLoader.fontSwitches; }
        function getFieldSpacing() { return itemLoader.fieldSpacing; }

        // The object source definition is passed complete from the calling group object
        // due to permit an empty string for loaders in the group that don't need to
        // load anything
        source: obj
    }

    // The connections to the possible signals returned by the objects
    Connections {
        target: objLoad.item
        // The ignoerUnknownSignals is set to true because not all the loadable objects
        // manages the same signals.
        ignoreUnknownSignals: true
        // Signal returned by the objects
        onObjClicked: { itemLoader.clicked(); }
        onSwitched: { itemLoader.switched(falgstate); }
    }
}
